package com.gxa.wmcrm.service.Impl;


import com.gxa.wmcrm.dao.LoginDaoNew;
import com.gxa.wmcrm.dao.impl.LoginDaoNewImpl;
import com.gxa.wmcrm.entity.Code;

import com.gxa.wmcrm.pojo.LoginEntity;
import com.gxa.wmcrm.service.UserServiceNew;

import java.util.HashMap;
import java.util.Map;

public class UserServiceNewImpl implements UserServiceNew {

    @Override
    public Map<String,Object> login(LoginEntity loginEntity, Code code) {

        Map<String,Object> resultMap = new HashMap<>();
        if (code.getCode().equals(code.getAdminCode())) {
            // 调用dao层的类
            // 登录 dao的接口  +  登录 dao 的实现类
            LoginDaoNew loginDaoNew = new LoginDaoNewImpl();
            long count = loginDaoNew.queryUser(loginEntity);
            if (count == 1) {
                resultMap.put("Status","success");
                resultMap.put("Text","登录成功!");
            } else {
                resultMap.put("Status","error");
                resultMap.put("Text","登录失败！");
            }
        } else {
            resultMap.put("Status","error");
            resultMap.put("Text","验证码错误！");
        }
        return resultMap;
    }
}


